<?php
class AppAction extends Action{
	
	public function get_app_list(){

		$ids = M('company_app_rds','','DB_MEETING')->db(2,'DB_CONFIG1')->where('cid = '.$_GET['cid'])->select();
		$appid = '';
		foreach($ids as $val)
		{
			if($appid == '')
				$appid .= $val['app_id'];
			else
				$appid .= ','.$val['app_id'];
		}
		$val = null; unset($val);


		if(!$appid)
			$rs=M('teamin_app','','')->db(1,'DB_CONFIG2')->where('app_openUrl!="TeamInHome" and app_project="Teamin"')->select();
		else
			$rs=M('teamin_app','','')->db(1,'DB_CONFIG2')->where('app_openUrl!="TeamInHome" and app_project="Teamin" and app_id in ('.$appid.')')->select();


		if($rs)
			return_json(0,$rs);
		else
			retrun_json(40001);
	}
	
	public function to_update(){
		if($_GET['app_openUrl']==''){
			return_json(40067);
			return;	
		}
		if($_GET['mobile_type']!='android')
			$cows = 'app_downloadUrl,app_version,ios_update_why';
		else
			$cows = 'android_url as app_downloadUrl,android_version as app_version,android_update_why';
		$sql ='select '.$cows.' from teamin_app';
		$sql.=' where app_openUrl="'.$_GET['app_openUrl'].'"';
		$sql.=' limit 1';
		$rs=M('teamin_app','','')->db(1,'DB_CONFIG2')->query($sql);
		if($rs[0])
			return_json(0,$rs[0]);
		else
			retrun_json(40001);
	}
}
?>